package com.dodoke.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dodoke.dto.RetailAccountDTO;
import com.dodoke.entity.RetailAccount;
import com.dodoke.vo.RetailAccountListVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * 人员/商户数据库操作接口
 */
@Mapper
public interface RetailAccountMapper extends BaseMapper<RetailAccount> {

    /**
     * 人员/商户分页查询
     *
     * @param page
     * @param retailAccountDTO
     * @return
     */
    Page<RetailAccountListVO> selectByList(Page<RetailAccountListVO> page, @Param("retailAccountDTO") RetailAccountDTO retailAccountDTO);

    /**
     * 新增人员/商户
     *
     * @param retailAccount
     * @return
     */
    int insertRetailAccount(RetailAccount retailAccount);

    /**
     * 修改人员/商户
     *
     * @param retailAccount
     * @return
     */
    int updateRetailAccount(RetailAccount retailAccount);

    /**
     * 根据(门店/网点)或商户id 清空负责人
     * @param fromId
     * @param type 类型0:门店,1:商户
     */
    void clearMainPersonByFromId(@Param("fromId") Long fromId, @Param("type") String type);

    /**
     * 根据id设置负责人
     * @param id
     */
    int setMainPerson(Long id);
}
